<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 方法1
        var cols1 = prompt('请输入您想要打印的列数');
        var rows1 = prompt('请输入您想要打印的行数');
        for (var i = 1; i <= rows1; i++) {
            var str = '';
            for (var j = 1; j <= cols1; j++) {
                str += '★';
            }
            console.log(str);
        }
        // 方法2
        var cols2 = prompt('请输入您想要打印的列数');
        var rows2 = prompt('请输入您想要打印的行数');
        var num = '';
        for (var i = 1; i <= rows2; i++) {
            for (var j = 1; j <= cols2; j++) {
                num += '★';
            }
            num += '\n';
        }
        console.log(num);
    </script>
</head>

<body>

</body>

</html>